<%-- 
    Document   : news
    Created on : Sep 29, 2010, 2:46:37 PM
    Author     : M Bilal
--%>



<%@page import="wap.rockvilletech.portal.DBProc"%>
<%@ page import="java.io.*,java.sql.*,java.net.*"%>
<%@ page import="org.apache.log4j.Logger" %>
<%@ include file="../includes/header.jspf"%>
<%
            thisPage = "News-Home";
            final Logger log = Logger.getLogger("JSP.INDEX.News.jsp");


            int attemptcount = 0; // to count the current attempt number

            final int image_width_final = 60;
            String strImageURL = "";
            boolean is_Image = false;
            int totalItmesInChannel = 0;
            int feed_li = 5; // number of items to show in each feed
            int intFetchNews = 6;
            String strFeedId = "";
            String[] arrFeedId = new String[]{"52-Latest News", "54-Urdu News", "53-Sports News", "58-LifeStyle News"};//52-Latest News","54-Urdu News","53-Sports News","51-LifeStyle News

            String str_feed_title = "", ititle = ""; // current feed heading
            int count = 0, intNewsId = 0; // feed_li counter
            String[] arrNews = null;
            DBProc db = DBProc.getInstance();
            Vector vRSSNews = null;
            boolean hasImageDisplay = true;
%>
<div align="center">
    <div style="background-color: #dedfe1;padding-top:10px;background-image:url('../images/new/top_bar.jpg');background-repeat: repeat-x;background-position:0% 350%;" title="">
        <a href="<%=context_Path%>/index.jsp"><img src='<%=context_Path%>/imgsrv?img=home<%=sImgFix%>.jpg&repo=PI&s=0&w=<%=mainButtonImgWidth%>' alt="home" title="Home"></a>
        <a href="<%=context_Path%>/content/index.jsp?app=Bollywood"><img src='<%=context_Path%>/imgsrv?img=downloads<%=sImgFix%>.jpg&repo=PI&s=0&w=<%=mainButtonImgWidth%>' alt="downloads" title="Downloads"></a>
        <a href="<%=context_Path%>/coolstuff/index.jsp"><img src='<%=context_Path%>/imgsrv?img=cool_stuff<%=sImgFix%>.jpg&repo=PI&s=0&w=<%=mainButtonImgWidth%>' alt="coolstuff" title="CoolStuff"></a>
        <img src='<%=context_Path%>/imgsrv?img=news_selected<%=sImgFix%>.jpg&repo=PI&s=0&w=<%=mainButtonImgWidth%>' alt="news" title="News">
    </div>
    <%
                for (int rss = 0; rss < arrFeedId.length; rss++) {
                    strFeedId = arrFeedId[rss].substring(0, 2).trim();
                    str_feed_title = arrFeedId[rss].substring(3);
                    vRSSNews = db.getRSSNews(strFeedId, intFetchNews);
                    if (vRSSNews != null && !vRSSNews.isEmpty()) {
    %>
    <table cellspacing="0" width="100%">
        <tr><td align="left" style="padding:5px 0px 0px 10px;">
                <table bgcolor="#d5d5d5" border="0" cellpadding="0" cellspacing="0">
                    <tr>
                        <td><img src="<%=context_Path%>/images/bar_left.png" alt="" /></td>
                        <td><b>&nbsp;<%=str_feed_title%>&nbsp;</b></td>
                        <td><img src="<%=context_Path%>/images/bar_right.png" alt="" /></td>
                    </tr>
                </table>
            </td></tr>
        <tr><td align="center" style="background-image:url('../images/new/catagory_top_part.jpg');background-repeat: repeat-x; padding:6px 0px 0px 0px; ">

                <div id="NewsBlock" class="NewsBlock" style="<%=css_NewsBlock%>">
                    <%
                        try {
                            totalItmesInChannel = vRSSNews.size();
                            count = 0;
                            for (int ptr = 0; ptr < vRSSNews.size(); ptr++) {//id,channel_id,headline,imgpath,newsdate
                                try {
                                    arrNews = (String[]) vRSSNews.get(ptr);
                                    strImageURL = arrNews[3];
                                    is_Image = (!strImageURL.equals("")) && strImageURL.length() > 1 && strImageURL != null ? true : false;
                                    if (is_Image && hasImageDisplay) {
                    %>
                    <a class="newsFeed" href="news/content_category.jsp?page=<%=thisPage%>&feed=<%=strFeedId%>&ftitle=<%=strFeedId%>">
                        <img src="<%=context_Path%>/imgsrv?img=<%=strImageURL%>&s=0&repo=http&w=<%=image_width_final%>" alt="" style="<%=css_Img%>" align="left" />
                    </a>
                    <%
                                    hasImageDisplay = false;
                                }
                                intNewsId = Integer.parseInt(arrNews[0]);
                                ititle = arrNews[2];
                                ititle = wap.rockvilletech.util.StringUtils.toUnicode(ititle);
                                if (count == 0) {
                                    //out.println("<ul>");
                                }
                    %>
                    <div style="<%=css_NewsBlock_Para%>">
                        <img src="<%=context_Path%>/images/bullet-dot-green.png" alt=""/>&nbsp;<a class="newsFeed" href="<%=context_Path%>/news/content.jsp?page=<%=thisPage%>&feed=<%=strFeedId%>&newsitemid=<%=intNewsId%>&ftitle=<%=strFeedId%>"><%=ititle%></a>
                    </div>
                    <%
                                } catch (Exception e) {
                                    e.printStackTrace();
                                }
                                count++;
                                if (count >= feed_li) {
                                    break;
                                }
                            } // end - for loop for items
                            if (count > 0) {
                                //out.println("</ul>");
                            }
                        } catch (Exception e) {
                            log.error("News index page", e);
                        }
                    %>
                    <div id="more" class="more" style="<%=css_NewsBlock_more%>">
                        <%
                            if (totalItmesInChannel > feed_li) {
                        %>
                        <a class="newsFeed" href="<%=context_Path%>/news/content_category.jsp?page=<%=thisPage%>&feed=<%=strFeedId%>&ftitle=<%=strFeedId%>">more</a>
                        <%
                            }
                            totalItmesInChannel = 0;
                        %>
                    </div>

                    <div class="clearFloat"></div>


                </div>
            </td>
        </tr>
    </table>
    <%
                    }//end if or check vector is null or not
                }//end of for loop external
    %>

    <%@include file="/includes/horizontal_bottom_menu.jspf"%>
    <%@ include file="../includes/others.jspf"%>
    <div style="padding:0px 0px 0px 0px;text-decoration: underline;">
        <jsp:include page="../banner.jsp">
            <jsp:param name="w" value="<%=width%>"/>
        </jsp:include>
    </div>

    
</div>

<%@ include file="../includes/footer.jspf"%>


<%
wpb.LogVisit(strIP, thisPage, strGsm,strApn,strBrand,strModel, app,request.getQueryString());
%>